<?php

namespace app\admin\model;
use app\common\common;
use app\common\model\MemberWithdrawal as MemberWithdrawalModel;
use app\common\model\UserMoneyLog as UserMoneyLogModel;

class MemberWithdrawal extends MemberWithdrawalModel
{
    /**
     * 修改审核状态
     * @param $id   Id
     * @param $status   状态 2:通过 3:不通过
     * @param string $remarks   备注
     */
    public static function examine($id,$status,$remarks = ''){
        $data = [
            'status'    =>  $status,
            'remarks'   =>  $remarks,
            'update_time'   =>  date('Y-m-d H:i:s',time())
        ];
        self::where('id',$id)->update($data);

        //审核不通过返回金额
        if($status == 3){
            $withdrawal = self::where('id',$id)->find();
            //币种
            $currency = common::key_currency($withdrawal['currency']);
            UserMoneyLogModel::change($withdrawal['mid'],$currency,$withdrawal['money'],'withdrawal_failed',$id,'提现失败返回提现金额');
            if($withdrawal['charge_money'] > 0) UserMoneyLogModel::change($withdrawal['mid'],$currency,$withdrawal['charge_money'],'withdrawal_failed',$id,'提现失败返回提现手续费');
        }

    }


}